<template>
	<view class="main-view">
		<!-- <view>
		<text>userId</text><text>{{userId}}</text>
		</view> -->
		<view>
			<input placeholder="请输入报名id" class="theme-input" v-model="eId"/>
			<image class="little-logo "  @click="enrollFill" src="../../static/search.svg"></image>
			<image class="little-logo " @click="scan" src="../../static/scan.svg"></image>
			
			<!-- <view id="search" @click="enrollFill" class="iconfont icondoc_text_search" style="font-size:40upx;"></view> -->
		</view>
		<!-- <button>发起新报名</button>
		<button>个人信息</button>
		<button>管理模板</button>
		
		<button>参与过的报名</button>
		<button>发起过的报名</button> -->
		<view class="dashboard oper-board col-arrange">
			<view>
				<view class="oper-item col-arrange" >
					<image class="oper-logo " @click="newEnroll" src="../../static/calendar_badge_plus.svg"></image>
					<text class="oper-text">发起新报名</text>
				</view>
				<view class="oper-item col-arrange" >
					<image @click="launchedEnroll" class="oper-logo" src="../../static/paperplane.svg"></image>
					<text class="oper-text">发起过的报名</text>
				</view>
				<view class="oper-item col-arrange" >
					<image @click="filledEnroll" class="oper-logo"  src="../../static/arrow_up_doc.svg"></image>
					<text class="oper-text">参与过的报名</text>
				</view>
			
			</view>
			<view>
				<view class="oper-item col-arrange" >
					<image @click="templetMain" class="oper-logo" src="../../static/list_dash.svg"></image>
					<text class="oper-text">模板管理</text>
				</view>
				<view class="oper-item col-arrange" >
					<image @click="personInfo" class="oper-logo" src="../../static/person.svg"></image>
					<text class="oper-text">个人信息</text>
				</view>
				<view class="oper-item col-arrange" >
					<image @click="logOut" class="oper-logo" style="height:160upx;width:160upx;margin:20upx;" src="../../static/logout.svg"></image>
					<text class="oper-text">注销</text>
				</view>
			
			
			</view>
		</view>
		
		<!-- <view v-for="enrollMeta in enrollMetas" :key="enrollMeta.startTime">
			{{enrollMeta.title}}-{{formatDatetime.formatDatetime(new Date(enrollMeta.startTime))}}- {{enrollMeta.status}}
		</view>
		<button @click="more">加载更多</button> -->
	</view>
</template>
	
	

<script>
	import formatDatetime from "../../common/zdateutil.js"
	export default {
		
		data() {
			return {
				userId : "",
				enrollMetas : [],
				formatDatetime : null,
				eId : ""
			}
		},
		onBackPress(options) {  
			return true;
			// uni.navigateTo({
			// 	url : './main'
			// }) 
            // return true;  
        },  
		onLoad : function() {
			// console.log(formatDatetime.formatDatetime)
			this.formatDatetime = formatDatetime;
			var token;
			var vm = this;
			// 载入用户id
			uni.getStorage({
				key : 'userToken',
				success :function(res){
					token = res.data;
					vm.userId = token.userId;
				},
				fail : function(){
					uni.navigateTo({
						url : 'index'
					})
				}
			});
		},
		methods: {
			newEnroll : function(){
				uni.navigateTo({
					url : '../enroll/newEnrollDesc'
				})
			},
			more : function(){
				var vm = this;
				var param = {'length':10,'lastTimeLong':this.enrollMetas[this.enrollMetas.length - 1].startTime}
				this.$get(this.enrollurl + '/enroll/moreEnrollMeta',param,function(res){
					var data = res.data;
					if(data.code != 0){
						// vm.errorText = data.message;
						return;
					}
					vm.enrollMetas = vm.enrollMetas.concat(data.object);
				});
			},
			personInfo : function(){
				uni.navigateTo({
					url : 'info'
				})
			},
			templetMain : function(){
				uni.navigateTo({
					url : '../enroll/templetMain'
				})
			},
			enrollFill : function(){
				if(this.eId.length != 32){
					uni.showModal({
						title : '错误',
						content : '请输入合法的报名id',
						showCancel : false
					})
					return ;
				}
				uni.navigateTo({
					url : '../enroll/fillEnroll?eId='+this.eId
				})
			},
			filledEnroll : function(){
				uni.navigateTo({
					url : '../enroll/filledEnrollPage'
				})
			},
			launchedEnroll : function(){
				uni.navigateTo({
					url : '../enroll/launchedEnrollPage'
				})
			},
			logOut : function(){
				uni.removeStorage({
					key : 'userToken'
				})
				uni.navigateTo({
					url : './index'
				})
			},
			scan : function(){
				// #ifdef H5
					uni.showToast({
						title:'仅在小程序和APP端支持扫码功能',
						icon:"none"
					})
					return;
				// #endif
				// 允许从相机和相册扫码
				uni.scanCode({
					success: function (res) {
						// console.log(res.result)
						if(res.result.length != 32){
							return;
						}
						uni.navigateTo({
							url : '../enroll/fillEnroll?eId='+res.result
						})
					}
				});
			}
		}
	}
</script>

<style>
	@import "../../common/uni.css";
	@import '../../common/iconfont/main_icon.css';
	.main-view{
		width: 100%;
		flex-direction: column;
	}
	input{
		margin-top:25upx;
		margin-bottom: 25upx;
		margin-left: 30upx;
		/* background-color: rgba(231, 226, 226, 0.568); */
		
		height:40upx;
		width: 600upx;
		padding: 20upx;
		padding-left: 30upx;
		/* border-radius: 50upx; */
		/* border-bottom: 1upx solid black; */
	}
	#search{
		margin-top:25upx;
		margin-left: 15upx;
	}
	.oper-icon{
		font-size: 200upx;
		height:200upx;
		
		/* margin-bottom: 100upx; */
		/* width: 500upx; */
	}
	.oper-board{
		/* width: 200upx;; */
		margin-top:50upx;
		padding-top: 100upx;
		padding-bottom: 100upx;
		/* background-color: rgb(253, 253, 253); */
	}
	.oper-logo{
		width: 200upx;
		height:200upx;
	}
	.oper-text{
		width:200upx;
		text-align: center
		/* margin-left: 30upx; */
	}
	.oper-item{
		margin-left: 50upx;
		width: 200upx;
	}
	.little-logo{
		height:120upx;
		width: 80upx;
		margin-left: 10upx;
	}
</style>
